package com.uppfind.framework.dao.mybatis.generator.generator.config.converts;

import com.uppfind.framework.dao.mybatis.generator.generator.config.TypeConvert;
import com.uppfind.framework.dao.mybatis.generator.generator.config.rules.DBColumnType;

/**
 * SQLServer 字段类型转换
 * Created by xuliugen on 2017/7/6.
 */
public class SqlServerTypeConvert implements TypeConvert {

    //TODO 进行具体的转换
    public DBColumnType processTypeConvert(String fieldType) {
        String t = fieldType.toLowerCase();
        if (t.contains("char") || t.contains("text") || t.contains("xml")) {
            return DBColumnType.SQLSERVER_STRING;
        } else if (t.contains("bigint")) {
            return DBColumnType.SQLSERVER_LONG;
        } else if (t.contains("int")) {
            return DBColumnType.SQLSERVER_INTEGER;
        } else if (t.contains("date") || t.contains("time")) {
            return DBColumnType.SQLSERVER_DATE;
        } else if (t.contains("text")) {
            return DBColumnType.SQLSERVER_STRING;
        } else if (t.contains("bit")) {
            return DBColumnType.SQLSERVER_BOOLEAN;
        } else if (t.contains("decimal") || t.contains("numeric")) {
            return DBColumnType.SQLSERVER_DOUBLE;
        } else if (t.contains("binary") || t.contains("image")) {
            return DBColumnType.SQLSERVER_BYTE_ARRAY;
        } else if (t.contains("float") || t.contains("real")) {
            return DBColumnType.SQLSERVER_FLOAT;
        }
        return DBColumnType.SQLSERVER_STRING;
    }

}
